package com.hr.mes.dto;

/**
 * 序列化Flowable实体会产生异常：Could not write JSON: lazy loading outside command context;
 * nested exception is com.fasterxml.jackson.databind.JsonMappingException: lazy loading outside command context (through reference chain:
 * com.hr.mes.dto.Result["data"]->java.util.ArrayList[0]->org.flowable.task.service.impl.persistence.entity.TaskEntityImpl["variableInstances"])
 * 原因：TaskEntityImpl中的variableInstances属性是一个延迟加载的集合，而序列化时无法触发加载（因为 Flowable 的命令上下文已关闭）
 * 解决方案：不要直接序列化 Flowable 的实体类（如 TaskEntityImpl），而是创建一个 DTO（Data Transfer Object），仅包含需要的字段
 */
public class Task {

    private String id;

    private String name;

    private String assignee;

    public Task() {
    }

    public String getId() {
        return id;
    }

    public Task(String id, String name, String assignee) {
        this.id = id;
        this.name = name;
        this.assignee = assignee;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAssignee() {
        return assignee;
    }

    public void setAssignee(String assignee) {
        this.assignee = assignee;
    }

    @Override
    public String toString() {
        return "Task{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", assignee='" + assignee + '\'' +
                '}';
    }
}
